<template>
  <DaprPlusTable
    :table-title="$t('daprplus.auth.loginLog.title')"
    :entity="entity"
    :grid-options="gridOptions"
    :query-api="crudApi.getPage"
    :delete-api="crudApi.delete"
    :show-create="false"
    :show-edit="false"
  />
</template>

<script lang="ts" setup>
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DaprPlusTable } from '#/components/daprplus';
import { createCrudApi } from '#/api/daprplus';
import type { EntityInfo, IOutDto } from '#/utils/daprplus';

const baseUrl = '/identity/api/loginlog';
const crudApi = createCrudApi<never, LoginLogOutDto>(baseUrl);

const entity: EntityInfo = {
  code: 'LoginLog',
  display: '登录日志',
};

// 扩展配置
const gridOptions: VxeGridProps<LoginLogOutDto> = {
  columns: [
    { type: 'checkbox', width: 40 },
    {
      field: 'id',
      title: '编号',
      sortable: true,
      width: 130,
    },
    {
      field: 'ip',
      title: 'IP地址',
      sortable: true,
      width: 150,
    },
    {
      field: 'userAgent',
      title: 'User Agent',
      sortable: true,
      minWidth: 300,
    },
    {
      field: 'remark',
      title: '备注',
      sortable: true,
      minWidth: 200,
    },
    {
      field: 'createdTime',
      title: '登录时间',
      sortable: true,
      formatter: 'formatDateTime',
      width: 150,
    },
    {
      field: 'logoutTime',
      title: '登出时间',
      sortable: true,
      formatter: 'formatDateTime',
      width: 150,
    },
  ],
};

export interface LoginLogOutDto extends IOutDto {
  ip?: string;
  userAgent?: string;
  remark?: string;
  createdTime?: Date;
  logoutTime?: Date;
}
</script>

<style scoped></style>
